package com.huaxin.hxmoduleworkorder.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.huaxin.hxmoduleworkorder.common.enums.base.BaseCodeEnum;
import lombok.Getter;

/**
 * 发布类型枚举类
 */
@Getter
public enum InspectionOrderPublishType implements BaseCodeEnum {
    AUTO("auto", "自动"),
    MANUAL("manual", "手动");

    @EnumValue
    private final String code;
    private final String displayName;

    InspectionOrderPublishType(String code, String displayName) {
        this.code = code;
        this.displayName = displayName;
    }

    @JsonValue
    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDisplayName() {
        return displayName;
    }

    public static InspectionOrderPublishType of(String code) {
        if (code == null) return null;
        for (InspectionOrderPublishType e : values()) {
            if (e.getCode().equalsIgnoreCase(code)) return e;
        }
        return null;
    }

    public static boolean isValid(String code) {
        return of(code) != null;
    }
}
